/**
 * 保龄球获胜者
 *
 * @USER: Administrator
 * @DATE: 2024/9/15 下午4:18
 * @VERSION: 1.0.0
 */
public class LC2660 {
    public static void main(String[] args) {
        LC2660 lc2660 = new LC2660();
        int[] player1 = new int[]{9,7,10,7};
        int[] player2 = new int[]{10,2,4,10};
        System.out.println(lc2660.isWinner(player1,player2));
    }

    public int isWinner(int[] player1, int[] player2) {
        int weight1 = 0, weight2 = 0;
        int sum1 = 0, sum2 = 0;
        for (int i = 0; i < player1.length; i++) {
            sum1 += player1[i]*(weight1>0?2:1);
            weight1--;
            if (player1[i] == 10) {
                weight1=2;
            }
        }

        for (int i = 0; i < player2.length; i++) {
            sum2 += player2[i]*(weight2>0?2:1);
            weight2--;
            if (player2[i] == 10) {
                weight2=2;
            }
        }

        if (sum1 == sum2) {
            return 0;
        }else {
            return sum1 > sum2 ? 1 : 2;
        }
    }

}
